<?php


namespace app\voip\func;



use app\voip\model\EHomeType;
use function PHPSTORM_META\elementType;

class HomeTypeFunc
{
    /**
     * @param $data
     * @return array|false
     * @throws \Exception
     */
    static function addAll($data)
    {
        $ehometype=new EHomeType();
        return $ehometype->saveAll($data);
    }

    /**
     * @param $data
     * @return mixed
     * @throws \think\exception\DbException
     */
    static function checkSave($data)
    {
        $resultData=[];

        foreach ($data as $key=>$val)
        {
            $res=EHomeType::get(['type_name'=>$val]);
            if ($res){
                $resultData[$val]=$res->id;
            }else{
                $res=EHomeType::create(['type_name'=>$val]);
                $resultData[$val]=$res->id;
            }
        }

        return $resultData;
    }

    /**
     * @param $where
     * @return mixed
     */
    static public function find($where)
    {
        return EHomeType::get($where);
    }

}